package gameElements;

import java.awt.Color;


/**
 * GfxExplossion.java
 * 
 * Fredrik Wallenius and Peter Steiner 
 * DP08 - KTH - 2009
 *
 */
public class GfxExplossion extends GfxElement{
	
	private int explossionTimer;
	private int explossionsCounter;
	private int nrOfExplossions;
	
	public GfxExplossion(double x_, double y_, Color color_, int noOfExpl_){
		super(x_, y_, color_);	
		explossionTimer = 0;
		destroyable = false;
		explossionsCounter=0;
		nrOfExplossions = noOfExpl_;
		
	}

	/**
	 * Move override, Increase exploxion tick timer.
	 */
	public void move(){
		explossionTimer++;
		resetExplossionTimer();
		if(explossionsCounter> nrOfExplossions){
			terminateExplossion();
		}
	}

	/**
	 * Method checks if explossion timer
	 * reached max limit
	 */
	private void resetExplossionTimer(){
		if(explossionTimer >40){explossionTimer = 0; explossionsCounter++;}
	}

	/**
	 * Method returns explossion picture index
	 * @return int
	 */
	public int getExplossionIndex(){
		return explossionTimer/4;
	}	
	
	/**
	 * Method sets this objects live statse to false
	 * In other words , it tells it its ready to die 
	 * 	 
	 */
	public void terminateExplossion(){
		destroyable = true;
	}
}

